<?php
  // no direct access
  defined( '_JEXEC' ) or die( 'Restricted access' );
  jimport( 'joomla.application.component.view');
  
  class TeamViewTeam extends JView
  {           
    var $_name = "team";
  
    function display()
    {
      $this->displayList();
    }
  
    function displayList()
    { 
       
      $state =& $this->get( 'state' );
            $lists['order_Dir'] = $state->get($this->_name . 'filter_order_Dir');
            $lists['order']     = $state->get($this->_name . 'filter_order');
            $this->assignRef('lists', $lists);    
      
      $teams = $this->get('ListData');
      $pagination = $this->get('Pagination');
      $this->assign('teams', $teams);
      $this->assign('pagination', $pagination);
      
      JToolBarHelper::title( JText::_( 'Teams' ), 'generic.png' );  
      
      JToolBarHelper::publishList();
      JToolBarHelper::unpublishList();
      JToolBarHelper::addNew();
      JToolBarHelper::editList();
      JToolBarHelper::deleteList();
      
      PBNYHelper::createMenu();
      
      parent::display("list");
    }
    
    function displayAdd()
    {    
      $editor =& JFactory::getEditor();
      $this->assign('editor', $editor);    
    
      JToolBarHelper::title( JText::_( 'Add Team' ), 'generic.png' );
      JToolBarHelper::save();
      JToolBarHelper::cancel();  

      parent::display("edit");
    }    
    
    function displayEdit()
    {    
      $model = $this->getModel();
      $cids = JRequest::getVar('cid', null, 'default', 'array' );
      $team = $model->get  ($cids[0]);
      $this->assign('team', $team);
      
      $mpic = $this->getModel('pic','picmodel');
      if($team->pic_id){
        $pic = $mpic->get($team->pic_id);
        $this->assign('pic', $pic);
      }
      
      if($team->logo_id){
        $logo = $mpic->get($team->logo_id);
        $this->assign('logo', $logo);
      }
      
      $editor =& JFactory::getEditor();
      $this->assign('editor', $editor);
      
      JToolBarHelper::title( JText::_( 'Edit Team' ), 'generic.png' );
      JToolBarHelper::save();
      JToolBarHelper::cancel();  

      parent::display("edit");
    }    
  }
?>